home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Libraries
/
XCMD libraries 960603
/
xcmdWind.h
< prev
Wrap
C/C++ Source or Header
|
1996-01-31
|
5KB
|
131 lines
#pragma once
#include "xcmdBase.h"
#include "xcmdStrings.h"
// © Paul B. Beeken, Work In Progress, 1994-5
// Knowledge Software Consulting.
//
// These files are a mindlessly simple wrapper class for the
// basic XCMD operations. Only one instance of the xcmdBase class is
// generated per XCMD call but there may be many instances of the XCMDString
// class. I have used these classes to whip out XCMD/XFCNs within hours of
// receiving the specs. They work great for me but I will always consider
// suggestions.
//
// Please, please, please, in the unlikely event you should use this stuff
// for some commercial application I would appreciate you contacting me. If
// its for your own use, use away. Send email: knowsoft@ios.com
//
// As always: this file is presented as is with no warrantees expressed or implied.
// Swim at your own risk, etc. etc.
//
// This is the base class for all Xwindow objects.
// It is a decendant of the xcmdBase because, while there doesn't seem
// to be any specific prohibition to multiple windows per xcmd, it is a
// practical limitation. HC only maintains one windowPtr per xcmd call.
// Thus when I handle operations I can only deal with one window at a time.
// N.B. there can be multiple windows through multiple calls for the xcmd
// to open windows. The result of this is that the xcmd event called is for
// the front most window. The xcmd must either limit the windows or not assume
// anything about the state of the window when the event call is made.
//
// The idea is to override most of the default actions listed below.
class xcmdWindow : public xcmdBase {
public:
xcmdWindow( XCmdPtr xP, Boolean lockParams=false );
~xcmdWindow();
// Test for establishing if we entered as a result of a toolbox "event."
Boolean isWindowEvent( void ) { return xEventInfo != nil; }
// This is the entry point for handling events.
void doWindowEvent( void );
// These tools to help create windows and set properties.
CWindowPtr createWindow( short rID, ResType rType='WIND', Boolean flot=false );
CWindowPtr createWindow( Rect& r, xcmdString& title, short procID=palNoGrowProc, Boolean vis=true, Boolean flot=true );
void idleTime( long ticks=0 );
public:
// These are the default actions for the window. most do nothing.
// client should override these with special features.
virtual void doOpenWindow( int show=true ); // Window is openning, initialize, show if hidden?
virtual void doCloseWindow( void ); // Window is closing, clean up
virtual void doShowHide( Boolean showFlag ); // Handle events relating to app4Evt.
virtual void doEditEvent( short what ); // Handle events relating to editing.
virtual void doMenuUpdate( void ); // A menuBar click, set up menus
virtual void doMenuClick( long m, long i ); // A menu click
virtual void doMessage( const xcmdString& msg ); // a send message to window...
virtual void doSetProperty( const xcmdString& prop, const xcmdString& val ); // set a window property
virtual xcmdString* doGetProperty( const xcmdString& prop ); // get a window property (nil returned if invalid request)
virtual void doCursorWithin( void ); // cursor is within the window */
// These are the default actions for the standard event switches
// notice that this list is not exhaustive. If you wish to respond to other
// events you need to supercede the doWindowEvent member above and handle the other
// events.
virtual void doIdleStuff( void ); // only gets called if idleTime > 0
virtual void doKeyDown( char keyChar, unsigned short modifiers=0 );
virtual void doMouseDown( short part );
virtual void doActiveWindow( Boolean activating );
virtual void doUpdateWindow( void );
virtual void doDrawWindow( void );
protected:
// These code wrappers are to be used with extreme caution as they require special
// timing and consideration. Make sure you understand how to use them and what
// they mean.
void allowReEntrancy( Boolean sysEvt, Boolean hcEvt );
void hasInteruptCode( Boolean hasIcode );
void alwaysMoveHigh( Boolean doIt );
void close( void );
short registerMenu( Boolean reg, short mResID );
// Use to register for text editing services.
void beginEdit( void );
void endEdit( void );
// These functions must be used with great care.
// I don't check to see if the xEvent pointer is valid.
CWindowPtr getXWindow( void );
void* getXEventParam( int i );
void setXEventResult( xcmdString* rv );
EventRecord* getXEvent( void );
Handle getPrivateStorage( void ) { return xPrivStore; }
void setPrivateStorage( Handle h ) { xPrivStore = h; }
Boolean isHidden( void ) { return !(((CWindowPeek)getXWindow())->visible); }
Boolean isInBackground( void ) { return !(((CWindowPeek)getXWindow())->hilited); }
private:
// For exposure only. Private variables may change.
GrafPtr oldXPort; // copy of current port
XWEventInfoPtr xEventInfo; // the original XEvent ptr or nil if none.
Handle xPrivStore; // handle to "permanent" storage
CWindowPtr xWindow; // we are always a color window
EventRecord xEvent; // the event record
};
#ifndef topLeft
inline Point* topLeft(r)
{
return (((Point *) &(r))[0])
}
#endif
#ifndef botRight
inline Point* botRight(r)
{
return (((Point *) &(r))[1])
}
#endif